
    function getCurrentDateStr(){
    	var currentRawDate = new Date();
    	return getDateStr(currentRawDate); 
    }
  
    function getRoundDate(dateStr, beforeDaysNum, afterDaysNum){   		
		var arr = dateStr.split('-');
		var roundDateArray = [];
		var tempDate;
		for(var i=(parseInt(arr[2]) - beforeDaysNum);i<=(parseInt(arr[2]) + afterDaysNum);i++){
			tempDate = new Date(arr[0],arr[1]-1,i);
			roundDateArray.push(getDateStr(tempDate));			
		}	
		return roundDateArray;
	 }
	 
	 function getDateStr(date){
   		var year = date.getFullYear(); 
		var month = date.getMonth()+1;//获取当前月份的日期 
		var day = date.getDate(); 
		
		return year + "-" + month + "-" + day; 
   	 }
   	 
   	 function getYearStr(dateStr){
   		var arr = dateStr.split('-'); 
   		var year = arr[0];
		
		return year; 
     }
     
     function getMonthStr(dateStr){
   		var arr = dateStr.split('-'); 
   		var month = arr[1];
		
		return month; 
     }
     
     function getDayStr(dateStr){
   		var arr = dateStr.split('-'); 
   		var day = arr[2];
		
		return day; 
     }
     
     function getDaysDuration(startDate, endDate){   
   		var endDateArray = endDate.split('-');
   		var startDateArray = startDate.split('-');
   		
   		//safari 只支持Y/M/D格式的New Date('Y/M/D');不能New Date('Y-M-D');
   		var endDateObj = new Date(endDateArray[0] + "/" + endDateArray[1] + "/" + endDateArray[2]);
   		var startDateObj = new Date(startDateArray[0] + "/" + startDateArray[1] + "/" + startDateArray[2]);
   		
   		var daysDuration = parseInt((endDateObj  -  startDateObj) / 1000 / 60 / 60 /24) + 1;   		
   		
   		if(daysDuration > 0)
   			return daysDuration;
   		else
   			return 0;
     }

    function compareDateStr(oldDateStr, newDateStr){
        var oldDateStrArray = oldDateStr.split('-');
        var newDateStrArray = newDateStr.split('-');
        
        var formattedOldDate = new Date(oldDateStrArray[0] + "/" + oldDateStrArray[1] + "/" + oldDateStrArray[2]);
        var formattedNewDate = new Date(newDateStrArray[0] + "/" + newDateStrArray[1] + "/" + newDateStrArray[2]);
        
        if(formattedNewDate >= formattedOldDate)
            return true;
        else
            return false;
    }
  	  	
  	function getTomorrowDateStr(dateStr){   		
		var arr = dateStr.split('-');
		var tomorrowDate = new Date(arr[0],arr[1]-1,parseInt(arr[2])+1);

		return getDateStr(tomorrowDate);
	}
	
	function getYesterdayDateStr(dateStr){   		
		var arr = dateStr.split('-');
		var yesterdayDate = new Date(arr[0],arr[1]-1,parseInt(arr[2])-1);

		return getDateStr(yesterdayDate);
	}
	
	function getLatestValidBBTDateStr(xAxisDateArrayStr){
   		var temperature;
   		var xAxisDateArray = xAxisDateArrayStr.split(',');
   		
   		for(var i = xAxisDateArray.length - 1; i > 0; i--){
   			temperature = customerDateTemperatureMap.get(xAxisDateArray[i]);
   			if(temperature != "-")
   				return xAxisDateArray[i];
   		}
   		
   		return "-";
   }
   
   function getLatestValidMucusDateStr(xAxisDateArrayStr){
   		var mucus;
   		var xAxisDateArray = xAxisDateArrayStr.split(',');
   		
   		for(var i = xAxisDateArray.length - 1; i > 0; i--){
   			mucus = customerDateMucusMap.get(xAxisDateArray[i]);

   			if(mucus != "-")
   				return xAxisDateArray[i];
   		}
   		
   		return "-";
   }

	function getPreviousValidBBTDate(index, dateArrayStr){
		var validDate = "-";
		var dateArray = dateArrayStr.split(",");

		for(var i = index - 1; i >= 0; i--){
			var temperatureData = customerDateTemperatureMap.get(dateArray[i]);
			if(temperatureData != "-"){
				validDate = dateArray[i];
				break;
			}
		}

		return validDate;
	}

	function getNextValidBBTDate(index, dateArrayStr){
		var validDate = "-";
		var dateArray = dateArrayStr.split(",");

		for(var i = index + 1; i < dateArray.length; i++){
			var temperatureData = customerDateTemperatureMap.get(dateArray[i]);
			if(temperatureData != "-"){
				validDate = dateArray[i];
				break;
			}
		}

		return validDate;
	}

	function getFirstValidTemperatureDate(dateArrayStr){
		var dateStr = "-";
		var dateArray = dateArrayStr.split(",");

		for(var i = 0; i < dateArray.length; i++){
			if(customerDateTemperatureMap.get(dateArray[i]) != "-"){
				dateStr = dateArray[i];
				break;
			}
		}

		return dateStr;
	}

	function getPolishedTemperature(previousValidDateStr, currentDateStr, nextValidDateStr){
		var previousValidTemperature = customerDateTemperatureMap.get(previousValidDateStr);
		var nextValidTemperature = customerDateTemperatureMap.get(nextValidDateStr);
		var totalDuration = getDaysDuration(previousValidDateStr, nextValidDateStr) - 1;
		var deltaDuration = getDaysDuration(previousValidDateStr, currentDateStr) - 1;

		var deltaTemperature;
		var polishedTemperature;

		if(previousValidTemperature <= nextValidTemperature){
			deltaTemperature = nextValidTemperature - previousValidTemperature;
			polishedTemperature = previousValidTemperature + (deltaDuration * deltaTemperature / totalDuration).toFixed(2);
		}else{
			deltaTemperature = previousValidTemperature - nextValidTemperature;
			polishedTemperature = previousValidTemperature - (deltaDuration * deltaTemperature / totalDuration).toFixed(2);
		}

		return polishedTemperature;
	}